package com.hdu.hot100.oneDimensionalDp;

public class lc198 {
    class Solution {
        public int rob(int[] nums) {
            int len = nums.length;
            if (len == 1) return nums[0];
            else if (len == 2) return Math.max(nums[0], nums[1]);
            else {
                int a = nums[0];
                int b = Math.max(nums[0], nums[1]);
                for (int i = 2; i < len; i++)
                {
                    int tmp = Math.max(nums[i] + a, b);
                    a = b;
                    b = tmp;
                }
                return b;
            }
        }
    }
}
